package app.actions;

import app.frames.AddStudentForm;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JTree;
import libs.Attendance;

/**
 *  Spusteni dialogu pridani studenta
 * @author Dejvino
 */
public class AddStudentAction extends AbstractAction {

    private Attendance attendance = null;

    private JFrame frame = null;
    private JTree tree = null;

    public AddStudentAction(JFrame frame, Attendance attendance){
        if(attendance == null)
            throw new NullPointerException("attendance");
        this.frame = frame;
        this.attendance = attendance;
    }

    public void setTree(JTree tree)
    {
        if(tree == null)
            throw new NullPointerException("tree");
        this.tree = tree;
    }

    public void actionPerformed(ActionEvent arg0) {
        if(tree == null)
            throw new NullPointerException("tree is still null!");
        if(frame != null)
            frame.setEnabled(false);
        new AddStudentForm(frame, tree, attendance).setVisible(true);
    }

}
